﻿using System;
using System.Configuration;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace Sfd.Repositories.SqlClient
{
    public class RepositoryBase
    {
        public bool IsOnAzure { get; set; }

        public string ConnectionString
        {
            get
            {
                return IsOnAzure ? 
                    RoleEnvironment.GetConfigurationSettingValue("ProjectsDb") : 
                    ConfigurationManager.ConnectionStrings["ProjectsDb"].ConnectionString;

                //bool isAvailable;
                //try
                //{
                //    isAvailable = RoleEnvironment.IsAvailable;
                //}
                //catch (Exception)
                //{
                //    isAvailable = false;
                //}

                //return isAvailable ? 
                //    RoleEnvironment.GetConfigurationSettingValue("ProjectsDb") : 
                //    ConfigurationManager.ConnectionStrings["ProjectsDb"].ConnectionString;
            }
        }
    }
}
